﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FrbaCommerce.Login
{
    public partial class LoginAs : Form
    {

        private FormMenuPrincipal menuAnterior;
        private string nombreUsuario;
        

        public LoginAs(List<string> roles, FormMenuPrincipal anterior, string username)
        {
            Console.WriteLine("Iniciando LoginAs");
            InitializeComponent();
            this.menuAnterior = anterior;
            this.nombreUsuario = username;
            this.loginAs_accept.Enabled = false;
            foreach (string rol in roles)
            {
                roles_combo.Items.Add(rol);
            }

        }

        private void LoginAs_Load(object sender, EventArgs e)
        {

        }

        private void loginAs_accept_Click(object sender, EventArgs e)
        {
            string item = roles_combo.GetItemText(roles_combo.SelectedItem);
            menuAnterior.procesarLogin(item, this.nombreUsuario, this.menuAnterior);
            this.Close();
        }

        private void roles_combo_SelectedIndexChanged(object sender, EventArgs e)
        {
            string item = roles_combo.GetItemText(roles_combo.SelectedItem);
            if (item != "")
                this.loginAs_accept.Enabled = true;
            else
                this.loginAs_accept.Enabled = false;
        }


        public void salir()
        {
            this.Close();
        }


    }
}
